import Vue from "vue";
import Vuex from "vuex";
import createPersistedState  from 'vuex-persistedstate'
Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    user:{},
    userBalance: {},
    active:""
  },
  mutations: {
    updateUser(state,user){
      state.user = user;
    },
    //余额数据
    getBalance(state, userBalance) {
      state.userBalance = userBalance
    }
  },
  actions: {},
  modules: {},
  plugins:[createPersistedState({
    storage:window.sessionStorage,
    reducer(val){
      return{
        user:val.user,
        userBalance: val.userBalance
      }
    }
  })]
});
